package com.run.merchant.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.run.common.annotation.Log;
import com.run.common.core.controller.BaseController;
import com.run.common.core.domain.AjaxResult;
import com.run.common.enums.BusinessType;
import com.run.merchant.domain.WdInfo;
import com.run.merchant.service.IWdInfoService;
import com.run.common.utils.poi.ExcelUtil;
import com.run.common.core.page.TableDataInfo;

/**
 * 代取员提现申请Controller
 * 
 * @author run
 * @date 2025-05-12
 */
@RestController
@RequestMapping("/merchant/infowd")
public class WdInfoController extends BaseController
{
    @Autowired
    private IWdInfoService wdInfoService;

    /**
     * 查询代取员提现申请列表
     */
    @PreAuthorize("@ss.hasPermi('merchant:infowd:list')")
    @GetMapping("/list")
    public TableDataInfo list(WdInfo wdInfo)
    {
        startPage();
        List<WdInfo> list = wdInfoService.selectWdInfoList(wdInfo);
        return getDataTable(list);
    }

    /**
     * 导出代取员提现申请列表
     */
    @PreAuthorize("@ss.hasPermi('merchant:infowd:export')")
    @Log(title = "代取员提现申请", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WdInfo wdInfo)
    {
        List<WdInfo> list = wdInfoService.selectWdInfoList(wdInfo);
        ExcelUtil<WdInfo> util = new ExcelUtil<WdInfo>(WdInfo.class);
        util.exportExcel(response, list, "代取员提现申请数据");
    }

    /**
     * 获取代取员提现申请详细信息
     */
    @PreAuthorize("@ss.hasPermi('merchant:infowd:query')")
    @GetMapping(value = "/{wdId}")
    public AjaxResult getInfo(@PathVariable("wdId") Long wdId)
    {
        return success(wdInfoService.selectWdInfoByWdId(wdId));
    }

    /**
     * 新增代取员提现申请
     */
    @PreAuthorize("@ss.hasPermi('merchant:infowd:add')")
    @Log(title = "代取员提现申请", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WdInfo wdInfo)
    {
        return toAjax(wdInfoService.insertWdInfo(wdInfo));
    }

    /**
     * 修改代取员提现申请
     */
    @PreAuthorize("@ss.hasPermi('merchant:infowd:edit')")
    @Log(title = "代取员提现申请", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WdInfo wdInfo)
    {
        return toAjax(wdInfoService.updateWdInfo(wdInfo));
    }

    /**
     * 删除代取员提现申请
     */
    @PreAuthorize("@ss.hasPermi('merchant:infowd:remove')")
    @Log(title = "代取员提现申请", businessType = BusinessType.DELETE)
	@DeleteMapping("/{wdIds}")
    public AjaxResult remove(@PathVariable Long[] wdIds)
    {
        return toAjax(wdInfoService.deleteWdInfoByWdIds(wdIds));
    }
}
